package com.example.lib_base

import android.view.RoundedCorner
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions

object GlideUtils {

    fun loadImage(url:String,iv:ImageView){
        Glide.with(iv).load(url)
            .error(com.baidu.location.R.drawable.mtrl_ic_error)
            .placeholder(com.baidu.location.R.drawable.mtrl_ic_error)
            .into(iv)
    }

    fun loadCircleCropImage(url:String,iv:ImageView){
        Glide.with(iv).load(url)
            .error(com.baidu.location.R.drawable.mtrl_ic_error)
            .placeholder(com.baidu.location.R.drawable.mtrl_ic_error)
            .circleCrop()
            .into(iv)
    }

    fun loadRoundImage(url:String,iv:ImageView){
        Glide.with(iv).load(url)
            .error(com.baidu.location.R.drawable.mtrl_ic_error)
            .placeholder(com.baidu.location.R.drawable.mtrl_ic_error)
            .apply(RequestOptions.bitmapTransform(RoundedCorners(20)))
            .into(iv)
    }
}